//
//  SDChatMessage.m
//  SDChat
//
//  Created by Canny on 2018/10/29.
//  Copyright © 2018年 WK. All rights reserved.
//

#import "SDChatMessage.h"

@implementation SDChatMessage

-(instancetype)initWithChatMessageDic:(NSDictionary *)dic{
    self =[super init];
    if (self){
        self.content=[NSString stringWithFormat:@"%@",dic[@"content"]]; //消息
        self.msgID=[NSString stringWithFormat:@"%@",dic[@"id"]]; //消息id
        if ([dic[@"create_time"] integerValue]<100000) {
            self.create_time=[NSString stringWithFormat:@"%@",dic[@"create_time"]];
        }else{
            self.create_time=[MOLoadHttpsData GetTime:[dic[@"create_time"] integerValue]];
        }
        self.from=[NSString stringWithFormat:@"%@",dic[@"from"]];
        self.order_id=[NSString stringWithFormat:@"%@",dic[@"order_id"]];
        self.order_sn=[NSString stringWithFormat:@"%@",dic[@"order_sn"]];
        self.status=[NSString stringWithFormat:@"%@",dic[@"status"]];
        self.to=[NSString stringWithFormat:@"%@",dic[@"to"]];
        self.type=0; //消息类型
        NSInteger ID1 = [[LoginModel GetValue:DL_user_id] integerValue];
        NSInteger ID2 = [dic[@"from"] integerValue];

        if (ID1==ID2) {
            self.sender = @"1";//1是自己
        }else{
            self.sender = @"0";//0对方
        }

        
        
        //content = "\U53d1\U9001\U6d88\U606f\U800c\U8bbe\U8ba1";
        //"create_time" = 1542090765;
        //from = 2;
        //id = 62;
        //"is_deleted" = 0;
        //"modify_time" = 1542090765;
        //"order_id" = 476;
        //"order_sn" = otcsl201811131146410004637987;
        //status = 1;
        //to = 46;
        //type = 1;
    }
    return self;
}
+(instancetype)chatMessageWithDic:(NSDictionary *)dic{
    return [[self alloc]initWithChatMessageDic:dic];
}


@end
